This Jupyter notebook, describes how to access and visualize Infodengue’s datasets using the R language. For more information about the data and how to cite them, visit here.
To execute this notebook, the following libraries are necessary:
library(tidyverse)
Registered S3 methods overwritten by 'dbplyr':
method from
print.tbl_lazy
print.tbl_sql
── Attaching packages ────────────────────────────────────────────────── tidyverse 1.3.1 ──
✓ ggplot2 3.3.5 ✓ purrr 0.3.4
✓ tibble 3.1.4 ✓ dplyr 1.0.7
✓ tidyr 1.1.3 ✓ stringr 1.4.0
✓ readr 2.0.1 ✓ forcats 0.5.1
── Conflicts ───────────────────────────────────────────────────── tidyverse_conflicts() ──
x dplyr::filter() masks stats::filter()
x dplyr::lag() masks stats::lag()
library(tidyverse)
library(httr)
library(zoo)
Attaching package: ‘zoo’
The following objects are masked from ‘package:base’:
as.Date, as.Date.numeric
As tabelas geradas pelo Infodengue contem dados agregados por semana provenientes de diferentes fontes. Elas podem ser consultadas via formulário, ou diretamente do R, por meio de uma consulta à API.
Infodengue’s tables have data aggregated by week, provided by different sources. They could be consulted by a form, or directly from R, via consult of an API.
This functionality is available via the URL: https://info.dengue.mat.br/api/alertcity?params: must contain the following parameters:
geocode: city's IBGE code
disease: desease type to be consulted (str:dengue|chikungunya|zika)
format: file extension/format (str:json|csv)
ew_start: epidemiological week initial consultation (int:1-53)
ew_end: epidemiological week final consultation (int:1-53)
ey_start: year of initial consultation (int:0-9999)
ey_end: year of final consultation (int:0-9999)
Every parameter mentioned so far is obligatory for the consultation. The following example shows the requisition of the register of dengue between 1 and 52 of the year 2020, in Rio de Janeiro (geocodigo = 3304557) on CSV: :
How to do it using R?
1. Define the parameters
Verify if the consult is correct:
cons1
[1] "https://info.dengue.mat.br/api/alertcity?geocode=3304557&disease=dengue&format=csv&ew_start=1&ew_end=52&ey_start=2021&ey_end=2021"
2. Consulting:
glimpse(dados)
Rows: 40
Columns: 21
$ data_iniSE <date> 2021-01-03, 2021-01-10, 2021-01-17, 2021-01-24, 2021-01-31, 202…
$ SE <dbl> 202101, 202102, 202103, 202104, 202105, 202106, 202107, 202108, …
$ casos_est <dbl> 9, 11, 14, 30, 18, 17, 17, 25, 23, 32, 36, 43, 47, 74, 64, 41, 4…
$ casos_est_min <dbl> 9, 11, 14, 30, 18, 17, 17, 25, 23, 32, 36, 43, 47, 74, 64, 41, 4…
$ casos_est_max <dbl> 9, 11, 14, 30, 18, 17, 17, 25, 23, 32, 36, 43, 47, 74, 64, 41, 4…
$ casos <dbl> 9, 11, 14, 30, 18, 17, 17, 25, 23, 32, 36, 43, 47, 74, 64, 41, 4…
$ p_rt1 <dbl> 0.64216300, 0.73637200, 0.82569900, 0.99771600, 0.56761300, 0.24…
$ p_inc100k <dbl> 0.133377, 0.163016, 0.207475, 0.444588, 0.266753, 0.251933, 0.25…
$ Localidade_id <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
$ nivel <dbl> 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1…
$ id <dbl> 3.304557e+17, 3.304557e+17, 3.304557e+17, 3.304557e+17, 3.304557…
$ versao_modelo <date> 2021-10-13, 2021-10-13, 2021-10-13, 2021-10-13, 2021-10-13, 202…
$ tweet <dbl> 23, 20, 26, 28, 25, 16, 30, 38, 11, 142, 12, 24, 35, 19, 32, 13,…
$ Rt <dbl> 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1…
$ pop <dbl> 6747815, 6747815, 6747815, 6747815, 6747815, 6747815, 6747815, 6…
$ tempmin <dbl> 24, 24, 24, 25, 24, 22, 24, 23, 24, 23, 24, 24, 23, 21, 20, 20, …
$ umidmax <dbl> 90, 89, 84, 80, 85, 90, 95, 95, 90, 96, 93, 91, 93, 94, 92, 92, …
$ receptivo <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0…
$ transmissao <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
$ nivel_inc <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
$ notif_accum_year <dbl> 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032, 1032…
The available variables are:
3. Plotting examples